package edu.its.dreamteam.web.util;

import java.util.List;

import org.apache.tapestry.ValueEncoder;

import edu.its.dreamteam.daf.beans.Position;

public class PositionValueEncoder implements ValueEncoder<Position> {
	private List<Position> positionList;
	
	public PositionValueEncoder(List<Position> positionList) {  
		this.positionList = positionList;  
	} 
	public String toClient(Position position) {
		return position.getIdPosition();
	}

	public Position toValue(String value) {
		for(Position position : positionList) {  			      
			if(position.getIdPosition().equals(value)) {  
				return position;  
			}
		}  
		return null;  
	}	
}
